package com.itheima.mapper;

import com.itheima.pojo.Member;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface MemberMapper {
    /**
     * 根据会员id查询会员信息
     * @param memberId
     * @return
     */
    @Select("select * from member where id = #{memberId}")
    Member selectMemberByMemberId(Integer memberId);

    /**
     * 根据身份证号查询会员信息
     * @param idCard
     * @return
     */
    @Select("select * from member where id_card = #{idCard}")
    Member selectByIdCard(String idCard);

    /**
     * 添加会员信息
     * @param member
     * @return
     */
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into member(file_number, name, sex, id_card, phone_number, reg_time, password, email, birthday, remark) " +
            "values (#{fileNumber}, #{name}, #{sex}, #{idCard}, " +
            "#{phoneNumber}, #{regTime}, #{password}, #{email}, #{birthday}, #{remark})")
    Integer insert(Member member);

    /**
     * 根据手机号查询会员信息
     * @param telephone
     * @return
     */
    @Select("select * from member where phone_number = #{telephone}")
    Member selectByIdPhone(String telephone);
}
